<?
function del()
{
echo("<br> merge");
}

function afis()
{
  echo('</form>
  <table>   
    <form action="" name="testQR" method="post">
    
   <tr> <td> Username </td> <td> <input name="uname" type="text" value=""></td> </tr>
	<tr> <td> Nume </td> <td><input name="name" type="text" value=""></td> </tr>
    <tr> <td> 	 Prenume</td> <td> <input name="pren" type="text" value=""></td> </tr>
      
	<tr> <td> 	 <input type="submit" name="buton" value="Adauga" ></td> </tr>
 
	
	</form>');
	
	
	
	return 1;
	}
	  
	  
	  
	  


function returnTeste($qr,$handler)
{

//SELECT * FROM `projects` WHERE `ID` LIKE '1'

$result = mysql_query($qr);
if (!$result) {
    $message  = 'Invalid query: ' . mysql_error() . "\n";
    $message .= 'Whole query: ' . $query. "\n";
    die($message);
}





echo('<table width="200" border="1">');
$i=0;
echo('<form action="" name="testQR" method="post">');
echo('<tr>');

echo('<td><input name="name" type="text" value="Username"></td>');
echo('<td><input name="desc" type="text" value="Nume"></td>');
echo('<td><input name="stat" type="text" value="Prenume"></td>');echo('<td><input name="Detal" type="text" value="Details"></td>');
echo('</tr>'); 
echo('</form>');			
while ($row = mysql_fetch_assoc($result)) {
$i++;
?>
<form action="" name="testQR'.$i.'" method="post">
	<tr>
		
			<td><input name="name<?echo $i?>" type="text" value="<?echo $row['Username']?>" onclick="<? afis(); ?>"></td>
			<td><input name="desc'.$i.'" type="text" value="<?echo $row['Nume']?>"></td>
			<td><input name="stat'.$i.'" type="text" value="<?echo $row['Prenume']?>"></td>
			<td><input  type="submit" name="butonx<? echo $i?>" value="Sterge! >:) " ></td> 
			
			<? 
			$un=$_REQUEST['name'.$i.''];
			
			if(isset($_POST['butonx'.$i.''])) 
			{
			echo('xxxxxxxxxxxxxxxxxx');
			
			
			insert("DELETE FROM `testare` WHERE `Username` = '".$un."' LIMIT 1 ;",'');
			} ?>
			<?php
			//if(isset($_POST['name'.$i.''])) {
			//afis();
			//	}
?>
			
	
			
		
	</tr>	
</form>		
	<? } ?>
</table>

<?
}


function returnProject($qr,$handler)
{

//SELECT * FROM `projects`

$result = mysql_query($qr);
if (!$result) {
    $message  = 'Invalid query: ' . mysql_error() . "\n";
    $message .= 'Whole query: ' . $query;
    die($message);
}

$name=array();
$desc=array();
$stat=array();

echo('<table width="200" border="1">');
$i=0;

echo('<tr>');
echo('<td><input name="name" type="text" value="Nume proiect"></td>');
echo('<td><input name="desc" type="text" value="Descriere"></td>');
echo('<td><input name="stat" type="text" value="Status"></td>');
echo('</tr>'); 
while ($row = mysql_fetch_assoc($result)) {
$i++;
echo('<tr>');
echo('<td><input name="name'.$i.'" type="text" value="'.$row['Project_Name'].'"></td>');
echo('<td><input name="desc'.$i.'" type="text" value="'.$row['Description'].'"></td>');
echo('<td><input name="stat'.$i.'" type="text" value="'.$row['Status'].'"></td>');
echo('</tr>'); 
}

echo('</table>');
}




 function dbConn()
{
$username = "root";
$password = "";
$hostname = "localhost";	
$handler = mysql_connect($hostname, $username, $password) 
	or die("Unable to connect to MySQL");
print "Connected to MySQL<br>";

if (!mysql_select_db('test', $handler)) {
    echo 'Could not select database';
    exit;
}
return $handler;
}


function returnTable($qr,$handler)
{

//SELECT * FROM `projects` WHERE `ID` LIKE '1'

$result = mysql_query($qr);
if (!$result) {
    $message  = 'Invalid query: ' . mysql_error() . "\n";
    $message .= 'Whole query: ' . $query. "\n";
    die($message);
}

$name=array();
$desc=array();
$stat=array();
$id=array();



echo('<table width="200" border="1">');
$i=0;
echo('<form action="" name="testQR" method="post">');
echo('<tr>');

echo('<td><input name="name" type="text" value="Nume proiect"></td>');
echo('<td><input name="desc" type="text" value="Descriere"></td>');
echo('<td><input name="stat" type="text" value="Status"></td>');echo('<td><input name="Detal" type="text" value="Details"></td>');
echo('</tr>'); 
echo('</form>');			
while ($row = mysql_fetch_assoc($result)) {
$i++;
echo('<form action="detaliiProiect.php?xxx='.$row['ID'].'" name="testQR'.$i.'" method="post">');
	echo('<tr>');
		
			echo('<td><input name="name'.$i.'" type="text" value="'.$row['Project_Name'].'"></td>');
			echo('<td><input name="desc'.$i.'" type="text" value="'.$row['Description'].'"></td>');
			echo('<td><input name="stat'.$i.'" type="text" value="'.$row['Status'].'"></td>');
			echo('<td><input name="subm'.$i.'" type="submit" name="buton'.$i.'" value="Detalils" ></td> ');
		//	array_push($id, $row['ID']);
			
		
	echo('</tr>');	
echo('</form>');		
	}
echo('</table>');
return $id;

}

function dbClose($handler)
{
mysql_close($handler)
	or die("Error closing connection. Was the connection open before?");
echo "conexiune inchisa cu succes";

	
}

function insert($qr,$handler)
{

//SELECT * FROM `projects` WHERE `ID` LIKE '1'

$result = mysql_query($qr);
if (!$result) {
    $message  = 'Invalid query: ' . mysql_error() . "\n";
    $message .= 'Whole query: ' . $query;
    die($message);
}
/*
$name=array();
$desc=array();
$stat=array();

$result2=mysql_query("SELECT * FROM `projects` ;");

if ($result2)
{
echo('<table width="200" border="1">');
$i=0;
while ($row = mysql_fetch_assoc($result2)) {
$i++;
echo('<form action="detaliiProiect.php" name="testQR'.$i.'" method="post">');
	echo('<tr>');
		
		
			echo('<td><input name="name'.$i.'" type="text" value="'.$row['Project_Name'].'"></td>');
			echo('<td><input name="desc'.$i.'" type="text" value="'.$row['Description'].'"></td>');
			echo('<td><input name="stat'.$i.'" type="text" value="'.$row['Status'].'"></td>');
			echo('<td><input name="subm'.$i.'" type="submit" name="buton'.$i.'" value="Detalii"  action=""></td> ');
			
			
		
	echo('</tr>');	
echo('</form>');		
	}
echo('</table>');
}*/
}

function anyqr($qr,$handler)
{

//SELECT * FROM `projects` WHERE `ID` LIKE '1'

$result = mysql_query($qr);
if (!$result) {
    $message  = 'Invalid query: ' . mysql_error() . "\n";
    $message .= 'Whole query: ' . $query;
    die($message);
	
}

}
function anyqr2($qr,$handler)
{

//SELECT * FROM `projects` WHERE `ID` LIKE '1'

$result = mysql_query($qr);
if (!$result) {
    $message  = 'Invalid query: ' . mysql_error() . "\n";
    $message .= 'Whole query: ' . $query;
    die($message);
	
}
return $result;
}
/*
$name=array();
$desc=array();
$stat=array();



echo('<table width="200" border="1">');
$i=0;
while ($row = mysql_fetch_assoc($result)) {
$i++;
echo('<form action="" name="testQR'.$i.'" method="post">');
	echo('<tr>');
		
			echo('<td><input name="name'.$i.'" type="text" value="'.$row['Project_Name'].'"></td>');
			echo('<td><input name="desc'.$i.'" type="text" value="'.$row['Description'].'"></td>');
			echo('<td><input name="stat'.$i.'" type="text" value="'.$row['Status'].'"></td>');
			echo('<td><input name="subm'.$i.'" type="submit" name="buton'.$i.'" value="Modifica datele" ></td> ');
		
	echo('</tr>');	
echo('</form>');		
	}
echo('</table>');

}*/

?>